from bs4 import BeautifulSoup

file = 'D:\\idea_workspace\\python\\study-python-crawler\\test\\beautifulsoup\\find.html'

"""
（1）标签查找
（2）标签属性查找
"""


def test_find():
    with open(file, 'r') as f:
        #
        soup = BeautifulSoup(f, "html.parser")

        a = soup.find(name="a")
        print(type(a))


def test_test():
    with open(file, 'r') as f:
        #
        soup = BeautifulSoup(f, "html.parser")
        a = soup.find(name="a")

        # 标签内纯文本
        print(a.text)
        print(a.get_text())
        # 标签属性
        print(a.attrs)
        print(a.get("href"))


def test_attrs():
    with open(file, 'r') as f:
        #
        soup = BeautifulSoup(f, "html.parser")
        a = soup.find(name="a")
        # 标签属性
        print(a.attrs)
        print(a.get("href"))
